package com.imy.virtual.helper.utils;

import android.util.Log;

import com.imy.virtual.client.core.VirtualCore;

import java.io.File;
import java.io.IOException;

import mirror.dalvik.system.VMRuntime;

public class So64 {
  public static void fix64bitSoError() {
    Boolean call = VMRuntime.is64Bit.call(VMRuntime.getRuntime.call());
    Log.i("fix64bitSoError","is64bit:"+call);
    if (!call){
      return;
    }
    String nativeLibraryDir = VirtualCore.get().getContext()
        .getApplicationInfo().nativeLibraryDir;
    //查看所有目录
    File file = new File(nativeLibraryDir);
    Log.i("VApp","nativeLibraryDir:"+nativeLibraryDir);
    String soPath = String.format("/data/data/%s/lib/", VirtualCore.get().getContext()
        .getApplicationInfo().packageName);
    File soFile = new File(soPath);
    if (!soFile.exists()){
      // 复制目录
      soFile.mkdirs();
      File[] files = file.listFiles();
      for (int i = 0; i < files.length; i++) {
        File childFile = files[i];
        String targetPath=  soPath+childFile.getName();
        try {
          FileUtils.copyFile(childFile,new File(targetPath));
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }else {
      //是否so 有更新
    }
  }


}
